﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using StyleMVVM.DependencyInjection.Impl;

namespace StyleMVVM.DependencyInjection
{
	public class EnrichWithAttribute : Attribute, IEnrichWithAttribute
	{
		private Type enrichmentType;

		/// <summary>
		/// default constructor
		/// </summary>
		/// <param name="enrichmentType">enrichmentType must have a constructor that takes one parameter, the type to be enriched</param>
		public EnrichWithAttribute(Type enrichmentType)
		{
			this.enrichmentType = enrichmentType;
		}

		/// <summary>
		/// Priority with which to apply to enrich
		/// </summary>
		public int Priority { get; set; }

		public EnrichWithDelegate ProvideDelegate(Type attributedType, out int priority)
		{
			priority = Priority;

			return (container, context, injectedObject) => container.LocateByType(enrichmentType, injectedObject);
		}
	}
}
